﻿<ResourceDictionary 
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
  
  <Style TargetType="{x:Type TabControl}">
    <Setter Property="OverridesDefaultStyle" Value="True" />
    <Setter Property="SnapsToDevicePixels" Value="false" />
    <Setter Property="BorderThickness" Value="1" />
    <Setter Property="Background" Value="{StaticResource WindowBackgroundBrush}" />
    <Setter Property="BorderBrush" Value="{StaticResource SolidBorderBrush}" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type TabControl}">
          <Grid KeyboardNavigation.TabNavigation="Local">
            <Grid.RowDefinitions>
              <RowDefinition Height="Auto"/>
              <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
            <TabPanel Name="HeaderPanel" Grid.Row="0" Panel.ZIndex="1" Margin="0,0,4,-1" IsItemsHost="True" KeyboardNavigation.TabIndex="1" Background="Transparent" />
            <Border 
              Name="Border" 
              Grid.Row="1" 
              Background="{TemplateBinding Background}" 
              BorderBrush="{TemplateBinding BorderBrush}" 
              BorderThickness="{TemplateBinding BorderThickness}" 
              CornerRadius="1" 
              KeyboardNavigation.TabNavigation="Local"
              KeyboardNavigation.DirectionalNavigation="Contained"
              KeyboardNavigation.TabIndex="2" >
              <ContentPresenter Name="PART_SelectedContentHost" Margin="2,5,2,5" ContentSource="SelectedContent" />
            </Border>
          </Grid>
          <ControlTemplate.Triggers>
            <Trigger Property="IsEnabled" Value="False">
              <Setter Property="Foreground" Value="{StaticResource DisabledForegroundBrush}" />
              <Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource DisabledBorderBrush}" />
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
  
  <!-- TabItem -->
  <Style TargetType="{x:Type TabItem}">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type TabItem}">
          <Grid>
            <Border Name="Border" Margin="0,0,-4,0" CornerRadius="1,1,0,0"
                    Background="{StaticResource LightBrush}" BorderBrush="{StaticResource SolidBorderBrush}" BorderThickness="1,1,1,1">
              <ContentPresenter x:Name="ContentSite" VerticalAlignment="Center" HorizontalAlignment="Center"
                                ContentSource="Header" Margin="12,2,12,2" RecognizesAccessKey="True"/>
            </Border>
          </Grid>
          <ControlTemplate.Triggers>
            <Trigger Property="IsSelected" Value="True">
              <Setter Property="Panel.ZIndex" Value="100" />
              <Setter TargetName="Border" Property="Background" Value="{StaticResource WindowBackgroundBrush}" />
              <Setter TargetName="Border" Property="BorderThickness" Value="1,1,1,0" />
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
              <Setter TargetName="Border" Property="Background" Value="{StaticResource DisabledBackgroundBrush}" />
              <Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource DisabledBorderBrush}" />
              <Setter Property="Foreground" Value="{StaticResource DisabledForegroundBrush}" />
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
</ResourceDictionary>
